package com.example.jd.finance.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.baomidou.mybatisplus.annotation.TableId;
import com.example.jd.common.enums.NumberEnum;
import com.example.jd.common.enums.StatusEnum;
import com.example.jd.common.enums.TargetTypeEnum;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.time.LocalDateTime;
import java.io.Serializable;

/**
 * <p>
 * 
 * </p>
 *
 * @author admin
 * @since 2021-11-06
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class MsCustomerRecords extends Model<MsCustomerRecords> {

    private static final long serialVersionUID=1L;

    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    private Long bid;

    /**
     * 订单号
     */
    private String orderNum;

    /**
     * 客户id
     */
    private String customerId;

    /**
     * 通话id
     */
    private String callId;

    /**
     * 客户加密微信号
     */
    private String customerEncryptWechatCode;

    /**
     * 1-已申请，2-申请通过，3-申请失败，4-用户不存在，5-已接触 6-未添加
     */
    private Integer state;

    /**
     * 1-未分配，2-已分配
     */
    private Integer issueState;

    /**
     * 创建时间
     */
    private LocalDateTime createTime;

    /**
     * 修改时间
     */
    private LocalDateTime updateTime;

    /**
     * 0-正常 -1-删除
     */
    private Integer status;

    /**
     * 下发的企业微信号bid
     */
    private Long issueEnterpriseWechatBid;

    /**
     * 下发时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private LocalDateTime issueTime;

    /**
     * 申请时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private LocalDateTime applyTime;


    public static MsCustomerRecords generateMsCustomerRecords(Long bid,String orderNum,String callId, String customerId,String customerEncryptWechatCode){

        return MsCustomerRecords.builder()
                .bid(bid)
                .orderNum(orderNum)
                .customerId(customerId)
                .callId(callId)
                .customerEncryptWechatCode(customerEncryptWechatCode)
                .state(NumberEnum.ZERO.getCode())
                .status(StatusEnum.NORMAL.getCode())
                .createTime(LocalDateTime.now())
                .updateTime(LocalDateTime.now())
                .issueState(NumberEnum.ONE.getCode())
                .build();
    }

}
